package com.hsj.common.gateway.core;

import com.hsj.common.gateway.service.GatewayService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * @ClassName : StratLoad
 * @Description : 项目启动后自动执行
 * @Author : 康仕球
 * @Date: 2020-11-26 00:28
 */
@Slf4j
@Component
public class StratLoad implements ApplicationRunner {

    @Value("${spring.application.name}")
    private String serverName;

    @Value("${server.port}")
    private String pord;

    @Autowired
    private GatewayService gatewayService;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        log.info("----------------初始化加载网关路由-------------------");
        gatewayService.loadAllRouter();
        log.info("----------------------服务启动完成-----------------------");
        log.info("当前服务:" + serverName);
        log.info("当前端口:" + pord);
        log.info("-------------------------------------------------------\n\n");
    }
}
